#include <bits/stdc++.h>
using namespace std;

const int N = 1e5+5, Inf = 0x3f3f3f3f;
const long double eps = 1e-12;
int n, m, l, v, p[N], dp[N];
struct Car {
    int d, v, a;
} a[N];
vector<int> lef[N];

int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        cin >> n >> m >> l >> v;
        for (int i = 1; i <= n; i++) cin >> a[i].d >> a[i].v >> a[i].a;
        for (int i = 1; i <= m; lef[i].clear(), dp[i] = Inf, i++) cin >> p[i];
        int cnt = 0;
        for (int i = 1; i <= n; i++)
            if (a[i].a >= 0 && a[i].v > v) {
                int s = lower_bound(p + 1, p + m + 1, a[i].d) - p;
                if (s <= m) lef[s].push_back(m), cnt++;
            } else if (a[i].a > 0 && a[i].v <= v) {
                int s = lower_bound(p + 1, p + m + 1, a[i].d + (int)ceil((long double)(v * v - a[i].v * a[i].v) / a[i].a / 2)) - p;
                if (abs((long double)a[i].d + (v * v - a[i].v * a[i].v) / a[i].a / 2 - p[s]) <= eps) s++;
                if (s <= m) lef[s].push_back(m), cnt++;
            } else if (a[i].a < 0 && a[i].v > v) {
                int s = lower_bound(p + 1, p + m + 1, a[i].d) - p;
                int t = lower_bound(p + 1, p + m + 1, a[i].d + (int)ceil((long double)(a[i].v * a[i].v - v * v) / (-a[i].a) / 2)) - p - 1;
                if (s <= t && t <= m) lef[s].push_back(t), cnt++;
            }
        deque<pair<int, int>> cov;
        int j = 0;
        for (int i = 1; i <= m; i++) {
            int mn = Inf;
            for (int r : lef[i]) mn = min(mn, r);
            if (mn != Inf) {
                while (cov.size() && cov.back().second >= mn) lef[cov.back().first].clear(), cov.pop_back();
                cov.push_back({i, mn}), j++;
            }
            while (cov.size() && cov.front().second < i) cov.pop_front();
        }
        cov.clear();
        j = 0;
        dp[0] = 0;
        for (int i = 1; i <= m; i++) {
            while (cov.size() && cov.front().second < i) cov.pop_front();
            int mn = Inf;
            for (int r : lef[i]) mn = min(mn, r);
            if (mn != Inf) cov.push_back({i, mn}), j++, dp[j] = dp[j-cov.size()] + 1;
        }
        cout << cnt << " " << m - dp[j] << "\n";
    }
    return 0;
}